package com.qx.chat.system.event;

import java.io.Serializable;

import org.springframework.web.socket.WebSocketSession;

import com.qx.chat.system.message.Data;


/**
 * WebSocket Session相关事件
 * @see javax.websocket.Session
 * @author cyf
 *
 */
public class SessionEvent {

	/**
	 * 打开WebSocket 连接
	 * @author cyf
	 *
	 */
	public static class SessionOpen implements Serializable {

		private static final long serialVersionUID = -7600347876267975997L;

		private WebSocketSession session;

		private String loginName;

		public SessionOpen(String loginName, WebSocketSession session) {
			this.loginName = loginName;
			this.session = session;
		}

		public WebSocketSession getSession() {
			return session;
		}

		public void setSession(WebSocketSession session) {
			this.session = session;
		}

		public String getLoginName() {
			return loginName;
		}

		public void setLoginName(String loginName) {
			this.loginName = loginName;
		}

	}/**
	 * 转发消息到全体在线人员
	 * @author cyf
	 *
	 */
	public static class SessionAllOnlineMsg implements Serializable {

		private static final long serialVersionUID = -7600347876267975997L;

		private Data<?> data;

		private String loginName;

		public SessionAllOnlineMsg(String loginName, Data<?> data) {
			this.loginName = loginName;
			this.data = data;
		}

		public String getLoginName() {
			return loginName;
		}

		public void setLoginName(String loginName) {
			this.loginName = loginName;
		}

		public Data<?> getData() {
			return data;
		}

		public void setData(Data<?> data) {
			this.data = data;
		}

	}

	/**
	 * 关闭Websocket连接
	 * @author cyf
	 *
	 */
	public static class SessionClose implements Serializable {

		private static final long serialVersionUID = -3701789725873868399L;
		private WebSocketSession session;
		
		private String loginName;

		public SessionClose(String loginName,WebSocketSession session) {
			this.session = session;
			this.loginName = loginName;
		}

		public WebSocketSession getSession() {
			return session;
		}

		public void setSession(WebSocketSession session) {
			this.session = session;
		}

		public String getLoginName() {
			return loginName;
		}

		public void setLoginName(String loginName) {
			this.loginName = loginName;
		}

	}


	/**
	 * 关闭Websocket连接
	 * @author cyf
	 *
	 */
	public static class SessionError implements Serializable {

		private static final long serialVersionUID = -3701789725873868399L;
		private WebSocketSession session;
		
		private String loginName;

		public SessionError(String loginName,WebSocketSession session) {
			this.session = session;
			this.loginName = loginName;
		}

		public WebSocketSession getSession() {
			return session;
		}

		public void setSession(WebSocketSession session) {
			this.session = session;
		}

		public String getLoginName() {
			return loginName;
		}

		public void setLoginName(String loginName) {
			this.loginName = loginName;
		}

	}
	
	/**
	 * 丢失WebSocket主连接
	 * @author cyf
	 *
	 */
	public static class LostConnection implements Serializable{

		private static final long serialVersionUID = -352589589432753460L;
		
	}

}
